home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / Components.p < prev    next >
Text File  |  1996-05-01  |  13KB  |  375 lines

  1. {
  2.      File:        Components.p
  3.  
  4.      Contains:    Component Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Components;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __COMPONENTS__}
  28. {$SETC __COMPONENTS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC ComponentsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40.  
  41. {$PUSH}
  42. {$ALIGN MAC68K}
  43. {$LibExport+}
  44.  
  45. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  46.  
  47. CONST
  48.     kAppleManufacturer            = 'appl';                        {  Apple supplied components  }
  49.     kComponentResourceType        = 'thng';                        {  a components resource type  }
  50.  
  51.     kAnyComponentType            = 0;
  52.     kAnyComponentSubType        = 0;
  53.     kAnyComponentManufacturer    = 0;
  54.     kAnyComponentFlagsMask        = 0;
  55.  
  56.     cmpWantsRegisterMessage        = $80000000;
  57.  
  58.     kComponentOpenSelect        = -1;                            {  ComponentInstance for this open  }
  59.     kComponentCloseSelect        = -2;                            {  ComponentInstance for this close  }
  60.     kComponentCanDoSelect        = -3;                            {  selector # being queried  }
  61.     kComponentVersionSelect        = -4;                            {  no params  }
  62.     kComponentRegisterSelect    = -5;                            {  no params  }
  63.     kComponentTargetSelect        = -6;                            {  ComponentInstance for top of call chain  }
  64.     kComponentUnregisterSelect    = -7;                            {  no params  }
  65.     kComponentGetMPWorkFunctionSelect = -8;                        {  some params  }
  66.  
  67. {  Component Resource Extension flags  }
  68.     componentDoAutoVersion        = $01;
  69.     componentWantsUnregister    = $02;
  70.     componentAutoVersionIncludeFlags = $04;
  71.     componentHasMultiplePlatforms = $08;
  72.  
  73. {  Set Default Component flags  }
  74.     defaultComponentIdentical    = 0;
  75.     defaultComponentAnyFlags    = 1;
  76.     defaultComponentAnyManufacturer = 2;
  77.     defaultComponentAnySubType    = 4;
  78.     defaultComponentAnyFlagsAnyManufacturer = 3;
  79.     defaultComponentAnyFlagsAnyManufacturerAnySubType = 7;
  80.  
  81. {  RegisterComponentResource flags  }
  82.     registerComponentGlobal        = 1;
  83.     registerComponentNoDuplicates = 2;
  84.     registerComponentAfterExisting = 4;
  85.  
  86.  
  87. TYPE
  88.     ComponentDescriptionPtr = ^ComponentDescription;
  89.     ComponentDescription = RECORD
  90.         componentType:            OSType;                                    {  A unique 4-byte code indentifying the command set  }
  91.         componentSubType:        OSType;                                    {  Particular flavor of this instance  }
  92.         componentManufacturer:    OSType;                                    {  Vendor indentification  }
  93.         componentFlags:            LONGINT;                                {  8 each for Component,Type,SubType,Manuf/revision  }
  94.         componentFlagsMask:        LONGINT;                                {  Mask for specifying which flags to consider in search, zero during registration  }
  95.     END;
  96.  
  97.     ResourceSpecPtr = ^ResourceSpec;
  98.     ResourceSpec = RECORD
  99.         resType:                OSType;                                    {  4-byte code   }
  100.         resID:                    INTEGER;
  101.     END;
  102.  
  103.     ComponentResourcePtr = ^ComponentResource;
  104.     ComponentResource = RECORD
  105.         cd:                        ComponentDescription;                    {  Registration parameters  }
  106.         component:                ResourceSpec;                            {  resource where Component code is found  }
  107.         componentName:            ResourceSpec;                            {  name string resource  }
  108.         componentInfo:            ResourceSpec;                            {  info string resource  }
  109.         componentIcon:            ResourceSpec;                            {  icon resource  }
  110.     END;
  111.  
  112.     ComponentResourceHandle                = ^ComponentResourcePtr;
  113.     ComponentPlatformInfoPtr = ^ComponentPlatformInfo;
  114.     ComponentPlatformInfo = RECORD
  115.         componentFlags:            LONGINT;                                {  flags of Component  }
  116.         component:                ResourceSpec;                            {  resource where Component code is found  }
  117.         platformType:            INTEGER;                                {  gestaltSysArchitecture result  }
  118.     END;
  119.  
  120.     ComponentResourceExtensionPtr = ^ComponentResourceExtension;
  121.     ComponentResourceExtension = RECORD
  122.         componentVersion:        LONGINT;                                {  version of Component  }
  123.         componentRegisterFlags:    LONGINT;                                {  flags for registration  }
  124.         componentIconFamily:    INTEGER;                                {  resource id of Icon Family  }
  125.     END;
  126.  
  127.     ComponentPlatformInfoArrayPtr = ^ComponentPlatformInfoArray;
  128.     ComponentPlatformInfoArray = RECORD
  129.         count:                    LONGINT;
  130.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  131.     END;
  132.  
  133.     ExtComponentResourcePtr = ^ExtComponentResource;
  134.     ExtComponentResource = RECORD
  135.         cd:                        ComponentDescription;                    {  registration parameters  }
  136.         component:                ResourceSpec;                            {  resource where Component code is found  }
  137.         componentName:            ResourceSpec;                            {  name string resource  }
  138.         componentInfo:            ResourceSpec;                            {  info string resource  }
  139.         componentIcon:            ResourceSpec;                            {  icon resource  }
  140.         componentVersion:        LONGINT;                                {  version of Component  }
  141.         componentRegisterFlags:    LONGINT;                                {  flags for registration  }
  142.         componentIconFamily:    INTEGER;                                {  resource id of Icon Family  }
  143.         count:                    LONGINT;                                {  elements in platformArray  }
  144.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  145.     END;
  146.  
  147.     ComponentParametersPtr = ^ComponentParameters;
  148.     ComponentParameters = PACKED RECORD
  149.         flags:                    UInt8;                                    {  call modifiers: sync/async, deferred, immed, etc  }
  150.         paramSize:                UInt8;                                    {  size in bytes of actual parameters passed to this call  }
  151.         what:                    INTEGER;                                {  routine selector, negative for Component management calls  }
  152.         params:                    ARRAY [0..0] OF LONGINT;                {  actual parameters for the indicated routine  }
  153.     END;
  154.  
  155.     ComponentRecordPtr = ^ComponentRecord;
  156.     ComponentRecord = RECORD
  157.         data:                    ARRAY [0..0] OF LONGINT;
  158.     END;
  159.  
  160.     Component                            = ^ComponentRecord;
  161.     ComponentInstanceRecordPtr = ^ComponentInstanceRecord;
  162.     ComponentInstanceRecord = RECORD
  163.         data:                    ARRAY [0..0] OF LONGINT;
  164.     END;
  165.  
  166.     ComponentInstance                    = ^ComponentInstanceRecord;
  167.     ComponentResult                        = LONGINT;
  168.  
  169. CONST
  170.     mpWorkFlagDoWork            = $01;
  171.     mpWorkFlagDoCompletion        = $02;
  172.     mpWorkFlagCopyWorkBlock        = $04;
  173.     mpWorkFlagDontBlock            = $08;
  174.     mpWorkFlagGetProcessorCount    = $10;
  175.  
  176.  
  177. TYPE
  178.     ComponentMPWorkFunctionHeaderRecordPtr = ^ComponentMPWorkFunctionHeaderRecord;
  179.     ComponentMPWorkFunctionHeaderRecord = RECORD
  180.         headerSize:                UInt32;
  181.         recordSize:                UInt32;
  182.         workFlags:                UInt32;
  183.         processorCount:            UInt16;
  184.         unused:                    UInt16;
  185.     END;
  186.  
  187.     ComponentMPWorkFunctionProcPtr = ProcPtr;  { FUNCTION ComponentMPWorkFunction(globalRefCon: UNIV Ptr; header: ComponentMPWorkFunctionHeaderRecordPtr): ComponentResult; }
  188.  
  189.     ComponentMPWorkFunctionUPP = UniversalProcPtr;
  190.  
  191. CONST
  192.     uppComponentMPWorkFunctionProcInfo = $000003F0;
  193.  
  194. FUNCTION NewComponentMPWorkFunctionProc(userRoutine: ComponentMPWorkFunctionProcPtr): ComponentMPWorkFunctionUPP;
  195.     {$IFC NOT GENERATINGCFM }
  196.     INLINE $2E9F;
  197.     {$ENDC}
  198.  
  199. FUNCTION CallComponentMPWorkFunctionProc(globalRefCon: UNIV Ptr; header: ComponentMPWorkFunctionHeaderRecordPtr; userRoutine: ComponentMPWorkFunctionUPP): ComponentResult;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $205F, $4E90;
  202.     {$ENDC}
  203.  
  204. TYPE
  205.     ComponentRoutineProcPtr = ProcPtr;  { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
  206.  
  207.     ComponentRoutineUPP = UniversalProcPtr;
  208.  
  209. CONST
  210.     uppComponentRoutineProcInfo = $000003F0;
  211.  
  212. FUNCTION NewComponentRoutineProc(userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
  213.     {$IFC NOT GENERATINGCFM }
  214.     INLINE $2E9F;
  215.     {$ENDC}
  216.  
  217. FUNCTION CallComponentRoutineProc(VAR cp: ComponentParameters; componentStorage: Handle; userRoutine: ComponentRoutineUPP): ComponentResult;
  218.     {$IFC NOT GENERATINGCFM}
  219.     INLINE $205F, $4E90;
  220.     {$ENDC}
  221.  
  222. TYPE
  223.     ComponentRoutine                    = ComponentRoutineProcPtr;
  224. {
  225.     The parameter list for each ComponentFunction is unique. It is 
  226.     therefore up to users to create the appropriate procInfo for their 
  227.     own ComponentFunctions where necessary.
  228. }
  229.     ComponentFunctionUPP                = UniversalProcPtr;
  230. {  Component Database Add, Delete, and Query Routines  }
  231. FUNCTION RegisterComponent(VAR cd: ComponentDescription; componentEntryPoint: ComponentRoutineUPP; global: INTEGER; componentName: Handle; componentInfo: Handle; componentIcon: Handle): Component;
  232.     {$IFC NOT GENERATINGCFM}
  233.     INLINE $7001, $A82A;
  234.     {$ENDC}
  235. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle; global: INTEGER): Component;
  236.     {$IFC NOT GENERATINGCFM}
  237.     INLINE $7012, $A82A;
  238.     {$ENDC}
  239. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $7002, $A82A;
  242.     {$ENDC}
  243. FUNCTION FindNextComponent(aComponent: Component; VAR looking: ComponentDescription): Component;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $7004, $A82A;
  246.     {$ENDC}
  247. FUNCTION CountComponents(VAR looking: ComponentDescription): LONGINT;
  248.     {$IFC NOT GENERATINGCFM}
  249.     INLINE $7003, $A82A;
  250.     {$ENDC}
  251. FUNCTION GetComponentInfo(aComponent: Component; VAR cd: ComponentDescription; componentName: Handle; componentInfo: Handle; componentIcon: Handle): OSErr;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $7005, $A82A;
  254.     {$ENDC}
  255. FUNCTION GetComponentListModSeed: LONGINT;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $7006, $A82A;
  258.     {$ENDC}
  259. {  Component Instance Allocation and dispatch routines  }
  260. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  261.     {$IFC NOT GENERATINGCFM}
  262.     INLINE $7007, $A82A;
  263.     {$ENDC}
  264. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  265.     {$IFC NOT GENERATINGCFM}
  266.     INLINE $7008, $A82A;
  267.     {$ENDC}
  268. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $700A, $A82A;
  271.     {$ENDC}
  272. {  Direct calls to the Components  }
  273. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance; ftnNumber: INTEGER): LONGINT;
  274.     {$IFC NOT GENERATINGCFM}
  275.     INLINE $2F3C, $0002, $FFFD, $7000, $A82A;
  276.     {$ENDC}
  277. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  278.     {$IFC NOT GENERATINGCFM}
  279.     INLINE $2F3C, $0000, $FFFC, $7000, $A82A;
  280.     {$ENDC}
  281. FUNCTION ComponentSetTarget(ci: ComponentInstance; target: ComponentInstance): LONGINT;
  282.     {$IFC NOT GENERATINGCFM}
  283.     INLINE $2F3C, $0004, $FFFA, $7000, $A82A;
  284.     {$ENDC}
  285. {  Component Management routines  }
  286. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance; theError: OSErr);
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $700B, $A82A;
  289.     {$ENDC}
  290. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  291.     {$IFC NOT GENERATINGCFM}
  292.     INLINE $7010, $A82A;
  293.     {$ENDC}
  294. PROCEDURE SetComponentRefcon(aComponent: Component; theRefcon: LONGINT);
  295.     {$IFC NOT GENERATINGCFM}
  296.     INLINE $7011, $A82A;
  297.     {$ENDC}
  298. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  299.     {$IFC NOT GENERATINGCFM}
  300.     INLINE $7015, $A82A;
  301.     {$ENDC}
  302. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  303.     {$IFC NOT GENERATINGCFM}
  304.     INLINE $7018, $A82A;
  305.     {$ENDC}
  306. {  Component Instance Management routines  }
  307. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  308.     {$IFC NOT GENERATINGCFM}
  309.     INLINE $700C, $A82A;
  310.     {$ENDC}
  311. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance; theStorage: Handle);
  312.     {$IFC NOT GENERATINGCFM}
  313.     INLINE $700D, $A82A;
  314.     {$ENDC}
  315. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  316.     {$IFC NOT GENERATINGCFM}
  317.     INLINE $700E, $A82A;
  318.     {$ENDC}
  319. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance; theA5: LONGINT);
  320.     {$IFC NOT GENERATINGCFM}
  321.     INLINE $700F, $A82A;
  322.     {$ENDC}
  323. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  324.     {$IFC NOT GENERATINGCFM}
  325.     INLINE $7013, $A82A;
  326.     {$ENDC}
  327. {  Useful helper routines for convenient method dispatching  }
  328. FUNCTION CallComponentFunction(VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  329.     {$IFC NOT GENERATINGCFM}
  330.     INLINE $70FF, $A82A;
  331.     {$ENDC}
  332. FUNCTION CallComponentFunctionWithStorage(storage: Handle; VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  333.     {$IFC NOT GENERATINGCFM}
  334.     INLINE $70FF, $A82A;
  335.     {$ENDC}
  336. FUNCTION DelegateComponentCall(VAR originalParams: ComponentParameters; ci: ComponentInstance): LONGINT;
  337.     {$IFC NOT GENERATINGCFM}
  338.     INLINE $7024, $A82A;
  339.     {$ENDC}
  340. FUNCTION SetDefaultComponent(aComponent: Component; flags: INTEGER): OSErr;
  341.     {$IFC NOT GENERATINGCFM}
  342.     INLINE $701E, $A82A;
  343.     {$ENDC}
  344. FUNCTION OpenDefaultComponent(componentType: OSType; componentSubType: OSType): ComponentInstance;
  345.     {$IFC NOT GENERATINGCFM}
  346.     INLINE $7021, $A82A;
  347.     {$ENDC}
  348. FUNCTION CaptureComponent(capturedComponent: Component; capturingComponent: Component): Component;
  349.     {$IFC NOT GENERATINGCFM}
  350.     INLINE $701C, $A82A;
  351.     {$ENDC}
  352. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  353.     {$IFC NOT GENERATINGCFM}
  354.     INLINE $701D, $A82A;
  355.     {$ENDC}
  356. FUNCTION RegisterComponentResourceFile(resRefNum: INTEGER; global: INTEGER): LONGINT;
  357.     {$IFC NOT GENERATINGCFM}
  358.     INLINE $7014, $A82A;
  359.     {$ENDC}
  360. FUNCTION GetComponentIconSuite(aComponent: Component; VAR iconSuite: Handle): OSErr;
  361.     {$IFC NOT GENERATINGCFM}
  362.     INLINE $7029, $A82A;
  363.     {$ENDC}
  364. {$ENDC}
  365. {$ALIGN RESET}
  366. {$POP}
  367.  
  368. {$SETC UsingIncludes := ComponentsIncludes}
  369.  
  370. {$ENDC} {__COMPONENTS__}
  371.  
  372. {$IFC NOT UsingIncludes}
  373.  END.
  374. {$ENDC}
  375.